<?php require_once('../../Connections/agriculture.php'); ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>发布咨询信息</title>
</head>

<body>

<?php
$poster=$_SESSION['poster'];
$title=$_POST['title'];
$content=$_POST['content'];

//如果发布者和内容都不为空,则插入信息
if($poster&&$content){
mysql_select_db($database_agriculture, $agriculture);

$infoSql="insert into message values(null,'".$title."','".$content."','未回','不显示','',NOW(),'0','".$poster."')";
$infoSqlResult=mysql_query($infoSql);
if($infoSqlResult){
?>
<script language="javascript">
alert("信息发布成功,正在进行审核!");
</script>
<?php
echo "<meta http-equiv=refresh content='0; url=expert.php'>";
}
}
?>


<?php 

if($poster!=""){
echo '<a href="expert.php">返回</a>';
echo '<form id="form1" name="form1" method="post" action="">
  <label>标题
  <input name="title" type="text" id="title" />
  </label>
  <p>
    <label>内容
    <textarea name="content" id="content"></textarea>
    </label>
  </p>
  <p>
    <label>
    <input type="submit" name="Submit" value="提交" onclick="return checkForm(form1)" />
    </label>
    <label>
    <input type="reset" name="Submit2" value="重置" />
    </label>
  </p>
</form>';
}else{
echo "<meta http-equiv=refresh content='2; url=login.php'>请先登陆再发布信息!";
}
?>

<script language="javascript">
function checkForm(){
if(!(form1.title.value&&form1.content.value)){
alert("您的填写不完整!");
return false;
}
return true;
}
</script>


</body>
</html>
